{extend name="platform/new_base" /}
{block name="resources"/}
{/block}
{block name="main"}
                <!-- page -->
                <form class="v-filter-container">
                    <div class="filter-fields-wrap">
                        <div class="filter-item clearfix">
                            <div class="filter-item__field">
                                <div class="v__control-group">
                                    <label class="v__control-label">流水单号</label>
                                    <div class="v__controls">
                                        <input type="text" id="records_no" class="v__control_input" autocomplete="off">
                                    </div>
                                </div>
                                <div class="v__control-group">
                                    <label class="v__control-label">会员信息</label>
                                    <div class="v__controls">
                                        <input type="text" id="search_text" class="v__control_input" placeholder="手机号码/会员ID/用户名/昵称" autocomplete="off">
                                    </div>
                                </div>

                                <div class="v__control-group">
                                    <label class="v__control-label">变动类型</label>
                                    <div class="v__controls">
                                        <select class="v__control_input" id="form_type" >
                                            <option value="">请选择类别</option>
                                            <option value="1">商城订单</option>
                                            <option value="2">订单退还</option>
                                            <option value="4">充值</option>
                                            <option value="8">余额提现</option>
                                            <option value="10">调整</option>
                                            {if $globalStatus==1 ||  $areaStatus==1 ||  $teamStatus==1}
                                            <option value="11">分红提现</option>
                                            {/if}
                                            {if $distributionStatus==1}
                                            <option value="12">分销提现</option>
                                            {/if}
                                            {if $microshopStatus==1}
                                            <option value="14">收益提现</option>
                                            {/if}
                                        </select>
                                    </div>
                                </div>

                                <div class="v__control-group">
                                    <label class="v__control-label">变动时间</label>
                                    <div class="v__controls v-date-input-control">
                                        <label for="orderTime">
                                            <input type="text" class="v__control_input pr-30" id="orderTime" placeholder="请选择时间" autocomplete="off" data-types="datetime">
                                            <i class="icon icon-calendar"></i>
                                            <input type="hidden" id="orderStartDate">
                                            <input type="hidden" id="orderEndDate">
                                        </label>
                                    </div>
                                </div>

                            </div>
                        </div>
                        <div class="filter-item clearfix">
                            <div class="filter-item__field">
                                <div class="v__control-group">
                                    <label class="v__control-label"></label>
                                    <div class="v__controls">
                                        <a class="btn btn-primary search"><i class="icon icon-search"></i> 搜索</a>
                                        <a class="btn btn-success ml-15 dataExcel">导出明细表</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

                <div class="screen-title">
                    <span class="text">流水列表</span>
                </div>
                <!--<ul class="nav nav-tabs v-nav-tabs">-->
                    <!--<li role="presentation" class="active"><a href="#" class="flex-auto-center">全部</a></li>-->
                    <!--<li role="presentation"><a href="#" class="flex-auto-center">提现流水</a></li>-->
                    <!--<li role="presentation"><a href="#" class="flex-auto-center">充值流水</a></li>-->
                    <!--<li role="presentation"><a href="#" class="flex-auto-center">消费流水</a></li>-->
                <!--</ul>-->
                <table class="table v-table table-auto-center">
                    <thead>
                        <tr>
                            <th>流水号</th>
                            <th>会员信息</th>
                            <th>变动类型</th>
                            <!--<th>变动状态</th>-->
                            <th>变动金额</th>
                            <th>变动手续费</th>
                            <th>变动时间</th>
                            <th class="operationLeft">操作</th>
                        </tr>
                    </thead>
                    <tbody id="list">
                    </tbody>
                </table>

                <nav aria-label="Page navigation" class="clearfix">
                    <ul id="page" class="pagination pull-right"></ul>
                </nav>
{/block}
{block name="script"}
<script>
    require(['util'],function(util){
        util.initPage(getAccountList);
        // util.layDate('#startDate');
        // util.layDate('#endDate');
        util.layDate('#orderTime',true,function(value, date, endDate){
            var h=date.hours<10 ?"0"+date.hours : date.hours;
            var m=date.minutes<10 ?"0"+date.minutes : date.minutes;
            var s=date.seconds<10 ?"0"+date.seconds : date.seconds;
            var h1=endDate.hours<10 ?"0"+endDate.hours : endDate.hours;
            var m1=endDate.minutes<10 ?"0"+endDate.minutes : endDate.minutes;
            var s1=endDate.seconds<10 ?"0"+endDate.seconds : endDate.seconds;
            var date1=date.year+'-'+date.month+'-'+date.date+' '+h+":"+m+":"+s;
            var date2=endDate.year+'-'+endDate.month+'-'+endDate.date+' '+h1+":"+m1+":"+s1;

            if(value){
                $('#orderStartDate').val(date1);
                $('#orderEndDate').val(date2);
            }
            else{
                $('#orderStartDate').val('');
                $('#orderEndDate').val('');
            }

        });
        function getAccountList(page_index){
            var records_no = $("#records_no").val();
            var search_text = $("#search_text").val();
            var start_date = $("#orderStartDate").val();
            var end_date = $("#orderEndDate").val();
            var form_type = $("#form_type").val();
            $.ajax({
                type : "post",
                url : "{:__URL('PLATFORM_MAIN/Finance/accountList')}",
                async : true,
                data : {
                    "page_index" : page_index, "search_text":search_text, "records_no":records_no, "form_type":form_type, "start_date":start_date, "end_date":end_date
                },
                success : function(data) {
                    var html = '';
                    if (data["data"].length > 0) {
                        for (var i = 0; i < data["data"].length; i++) {
                            html += '<tr>';
                            html += '<td>' + data["data"][i]["records_no"]+ '</div></td>';
                            html += '<td><a href="' + __URL('PLATFORM_MAIN/member/memberDetail?member_id=' + data["data"][i]["uid"]) + '" class="text-primary block mt-04">' + data["data"][i]["user_info"]+ '</a></td>';
                            html += '<td>' + data["data"][i]["type_name"] + '</td>';
                            html += '<td>' + data["data"][i]["number"] + '</td>';
                            html += '<td>' + data["data"][i]["charge"] + '</td>';
                            html += '<td>' + data["data"][i]["create_time"] + '</td>';
                            html += '<td class="operationLeft"><a class="btn-operation send" href="javascript:void(0);" data-id="' + data["data"][i]["id"]+ '" >详情</a></td>';
                            html += '</tr>';
                        }
                    } else {
                        html += '<tr><td colspan="6" class="h-200">暂无符合条件的数据记录</td></tr>';
                    }
                    $('#page').paginator('option', {
                        totalCounts: data['total_count']  // 动态修改总数
                    });
                    $("#list").html(html);
                    util.tips();
                    accountDetail();
                }
            });
        }
        $('.search').on('click',function(){
            util.initPage(getAccountList);
        });
        /**
         * 余额流水详情
         */
        function accountDetail(){
            $('.send').on('click',function(){
                var id = $(this).data('id');
                var url = __URL('PLATFORM_MAIN/Finance/accountDetail')+'&id='+id;
                util.confirm('流水详情', 'url:'+url,function(){

                })
            })
        }
        /**
         * 余额流水数据导出
         */
        $('.dataExcel').on('click',function(){
            var records_no = $("#records_no").val();
            var search_text = $("#search_text").val();
            var start_date = $("#orderStartDate").val();
            var end_date = $("#orderEndDate").val();
            var form_type = $("#form_type").val();
            window.location.href=__URL("PLATFORM_MAIN/Finance/balanceDataExcel?form_type="+form_type+"&records_no="+records_no+"&start_date="+start_date+"&end_date="+end_date+"&search_text="+search_text);
        })
    })
</script>
{/block}